<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <body>

        <ui:composition template="./adminTemplate.xhtml">

            <ui:define name="title">
                Edit Banner
            </ui:define>

            <ui:define name="contain">
                <h:form id="form">
                    <h2 class="ico_mug">Edit Banner</h2>
                    <h:panelGrid columns="3" cellpadding="8px" cellspacing="10px" id="panel" >
                        <h:outputLabel value="Title: " />
                        <p:inputText value="#{bannerBean.banner.title}" id="title" requiredMessage="Please input title" required="true" style="width: 196px"/>
                        <p:message for="title"/>

                        <h:outputLabel value="Image: " />
                        <p:column>
                            <p:graphicImage value="../#{bannerBean.banner.image}" width="100" id="img"/> 
                            <p:tooltip for="img">  
                                <p:graphicImage value="../#{bannerBean.banner.image}" />  
                            </p:tooltip>  
                            <br/>
                            <p:fileUpload value="#{bannerBean.banner.image}"  mode="simple" styleClass="ui-state-default"/>  
                        </p:column>
                        &nbsp;

                        <h:outputLabel value="Website link: " />
                        <p:inputText value="#{bannerBean.banner.link}" id="link" requiredMessage="Please input website link" required="true" style="width: 196px"/>
                        <p:message for="link"/>

                        <h:outputLabel value="Description: " />
                        <p:inputTextarea value="#{bannerBean.banner.description}" id="description" rows="3" style="width: 196px" />
                        <p:message for="description"/>

                        <h:outputLabel value="Status: " />
                        <p:selectOneRadio value="#{bannerBean.banner.status}" id="se" label="status">  
                            <f:selectItem itemLabel=" Enable" itemValue="true" />  
                            <f:selectItem itemLabel=" Disable" itemValue="false" />                                       
                        </p:selectOneRadio>
                        &nbsp;
                        <p:column colspan="2">
                            <p:commandButton value="Submit" actionListener="#{bannerController.editBanner}"  ajax="false" >
                                <f:setPropertyActionListener value="#{bannerBean.banner}" target="#{bannerBean.banner}"/>
                            </p:commandButton>
                            <p:commandButton type="reset" value="Reset" /> 
                        </p:column>
                    </h:panelGrid>
                    <p:messages autoUpdate="true" showDetail="true" showSummary="false" globalOnly="true"></p:messages> 
                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
